package com.lh.controller;

import com.lh.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: LuoHang
 * @Date: 2021/2/8 0:50
 * @Description
 */
@Controller
public class RoleController {
    @Autowired
    private RoleService roleService;

    @RequestMapping("/roleList")
    public ModelAndView roleList() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("admin/role_list");
        return modelAndView;
    }

    @RequestMapping("/getRoles")
    @ResponseBody
    public Map<String, Object> getRoles() {
        Map<String, Object> map = new HashMap<>(5);
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 3);
        map.put("data", roleService.getRoles());
        return map;
    }
}
